package com.example.book_libapp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckInputValue {

	private static final String USERNAME_PATTERN = "^[a-z0-9_-]{3,15}$";
	private Pattern pattern;
	private Matcher matcher;

	public CheckInputValue() {
		pattern = Pattern.compile(USERNAME_PATTERN);
	}

	public boolean registerPasswordcheck(String password, String repassword) {

		if (password.equals(repassword)) {
			return true;
		} else {
			return false;
		}

	}

	public boolean validateEmail(String email) {

		Pattern pattern;
		Matcher matcher;
		String EMAIL_PATTERN = "[a-zA-Z0-9+._%-+]{1,256}" + "@"
				+ "[a-zA-Z0-9][a-zA-Z0-9-]{0,64}" + "(" + "."
				+ "[a-zA-Z0-9][a-zA-Z0-9-]{0,25}" + ")+";
		pattern = Pattern.compile(EMAIL_PATTERN);
		matcher = pattern.matcher(email);
		return matcher.matches();

	}

	public boolean registerUserCheck(String username) {
		if (username.length() > 3) {
			return true;
		} else {
			return false;
		}
	}

	public boolean registerPasswordCheck(String password) {
		if (password.length() > 5) {
			return true;
		} else {
			return false;
		}
	}

	// khereglegchiin ner shalgakh
	public boolean loginUsername(String username) {
		if (username.length() > 0 || username == null) {
			return true;
		} else {
			return false;
		}
	}

	// password shalgakh
	public boolean loginPassword(String password) {
		if (null == password || password.length() > 0) {
			return true;
		} else {
			return false;
		}
	}
	
	// params shalgakh
		public boolean urlparams(String param) {
			if (null == param || param.length() > 0) {
				return true;
			} else {
				return false;
			}
		}

	// Tusgai temdeg
	public boolean LoginUsername(String username) {
		matcher = pattern.matcher(username);
		return matcher.matches();
	}

}
